package io.renren.modules.com.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.com.entity.ComContractImageEntity;
import io.renren.modules.com.service.ComContractImageService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.common.utils.R;




/**
 * 
 * 
 * @author pfp
 * @email 
 * @date 2017-07-16 09:34:53
 */
@RestController
@RequestMapping("comcontractimage")
public class ComContractImageController {
	@Autowired
	private ComContractImageService comContractImageService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("comcontractimage:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<ComContractImageEntity> comContractImageList = comContractImageService.queryList(query);
		int total = comContractImageService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(comContractImageList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{serialNo}")
	@RequiresPermissions("comcontractimage:info")
	public R info(@PathVariable("serialNo") Long serialNo){
		ComContractImageEntity comContractImage = comContractImageService.queryObject(serialNo);
		
		return R.ok().put("comContractImage", comContractImage);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("comcontractimage:save")
	public R save(@RequestBody ComContractImageEntity comContractImage){
		comContractImageService.save(comContractImage);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("comcontractimage:update")
	public R update(@RequestBody ComContractImageEntity comContractImage){
		comContractImageService.update(comContractImage);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("comcontractimage:delete")
	public R delete(@RequestBody Long[] serialNos){
		comContractImageService.deleteBatch(serialNos);
		
		return R.ok();
	}
	
}
